home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 January / PCWorld_2007-01_cd.bin / v cisle / hotkey / AutoHotkey104504_Install.exe / Extras / Generate PSPad.ahk < prev    next >
Text File  |  2005-02-08  |  4KB  |  118 lines

  1. ;;; ============================================================================
  2. ;;;   FILENAME: Generate PSPad.ahk
  3. ;;; ============================================================================
  4. ;;;   PSPad Syntax Generator Script
  5. ;;; ============================================================================
  6. ;;;   AUTHOR:  Scott Greenberg  
  7. ;;;   COMPANY: SG Technology
  8. ;;;   VERSION: 1.0.0, 02/08/2005 - 02/08/2005
  9. ;;;   WEBSITE: http://gogogadgetscott.info/
  10. ;;;
  11. ;;; ============================================================================
  12. ;;;   NOTE:
  13. ;;;    Derived from Rajat's PSPad Syntax Generator Script
  14. ;;; ============================================================================
  15.  
  16. SetBatchLines, -1     ; Speeds up file operations.
  17. SetWorkingDir, ..\..  ; Set it to the Editors folder.
  18.  
  19. TargetFile = PSPad\AutoHotkey.ini
  20. FileDelete, %TargetFile%
  21.  
  22. FileAppend, `; PSPad keyword syntax file for AutoHotkey`n, %TargetFile%
  23. FileAppend, `; Auto generated by GoGoGadgetScott's PSPad Syntax Generator Script`n`n, %TargetFile%
  24.  
  25. FileAppend, [Settings] `n, %TargetFile%
  26. FileAppend, Name=AutoHotkey `n, %TargetFile%
  27. FileAppend, HTMLGroup=0 `n, %TargetFile%
  28. FileAppend, FileType=*.ahk `n, %TargetFile%
  29. FileAppend, CommentString=; `n, %TargetFile%
  30. FileAppend, CComment=1 `n, %TargetFile%
  31. FileAppend, BasComment=1 `n, %TargetFile%
  32. FileAppend, SingleQuote=1 `n, %TargetFile%
  33. FileAppend, DoubleQuote=1 `n, %TargetFile%
  34. FileAppend, Preprocessors=1 `n, %TargetFile%
  35. FileAppend, KeyWordChars=-_# `n, %TargetFile%
  36. FileAppend, [KeyWords]`n, %TargetFile%
  37.  
  38.  
  39. ;this doesn't require fancy cmd names for human reading,
  40. ;it just requires names to be highlighted. so getting first name only
  41.  
  42. Loop, Read, Syntax\Commands.txt, %TargetFile%
  43. {
  44.     CurrCmd =
  45.     FullCmd = %a_loopreadline%
  46.     
  47.     ;directives don't have first comma but a first space
  48.     ;so whichever is first, take it as end of cmd name
  49.     StringGetPos, cPos, a_loopreadline, `,
  50.     StringGetPos, sPos, a_loopreadline, %A_Space%
  51.     
  52.     IfLess, sPos, %cPos%
  53.         IfGreater, sPos, 0
  54.             StringLeft, CurrCmd, a_loopreadline, %sPos%
  55.     
  56.     IfLess, cPos, %sPos%
  57.         IfGreater, cPos, 0
  58.             StringLeft, CurrCmd, a_loopreadline, %cPos%
  59.  
  60.     IfLess, cPos, %sPos%
  61.         IfLess, cPos, 0
  62.             StringLeft, CurrCmd, a_loopreadline, %sPos%
  63.  
  64.     IfLess, sPos, %cPos%
  65.         IfLess, sPos, 0
  66.             StringLeft, CurrCmd, a_loopreadline, %cPos%
  67.             
  68.     StringReplace, FullCmd, FullCmd, ``n, `n, a
  69.     StringReplace, FullCmd, FullCmd, ``t, `t, a
  70.  
  71.     StringReplace, CurrCmd, CurrCmd, [,, a
  72.     StringReplace, CurrCmd, CurrCmd, %a_space%,, a
  73.     
  74.     ;For a directive that has no parameters
  75.     IfEqual, CurrCmd,
  76.         CurrCmd = %a_loopreadline%
  77.     
  78.     
  79.     ;this check removes duplicates for loop and if
  80.     IfNotEqual, CurrCmd, %LastCmd%
  81.         FileAppend, %CurrCmd%=`n
  82.     
  83.     LastCmd = %CurrCmd%
  84. }
  85.  
  86.  
  87. FileAppend, `n[ReservedWords]`n, %TargetFile%
  88.  
  89. ;Adding keywords including the blank lines and comments
  90. Loop, Read, Syntax\Keywords.txt, %TargetFile%
  91.     FileAppend, %A_LoopReadLine%=`n
  92.  
  93. FileAppend, `n`n, %TargetFile%
  94.  
  95. FileAppend, `n[KeyWords2]`n, %TargetFile%
  96.  
  97. ;same with variables
  98. Loop, Read, Syntax\Variables.txt, %TargetFile%
  99.     FileAppend, %A_LoopReadLine%=`n
  100.  
  101.  
  102. FileAppend, `n[KeyWords3]`n, %TargetFile%
  103.  
  104. ;keys are added with and without {}
  105. Loop, Read, Syntax\Keys.txt, %TargetFile%
  106. {
  107.     FileAppend, %A_LoopReadLine%=`n
  108.     IfEqual, A_LoopReadLine,, Continue
  109.     
  110.     ;comment check
  111.     StringReplace, check, A_LoopReadLine, %A_Space%,, A
  112.     StringReplace, check, check, %A_Tab%,, A
  113.     StringLeft, check, check, 1
  114.     IfEqual, check, `;, Continue
  115.     
  116.     FileAppend, {%A_LoopReadLine%}=`n
  117. }
  118.